from django.urls import re_path
from rest_framework_jwt.views import obtain_jwt_token
from django.urls import path, include
from . import views

urlpatterns = [
    # 返回所有标签
    path("labels/", views.LabelallViewSet.as_view({
        "get": "list",
    })),
    # labels/full/
    path("labels/full/", views.LabelallViewSet.as_view({
        "get": "list",
    })),
    # 用户关注的标签
    path("labels/users/", views.LabelallViewSet.as_view({
        "get": "retrieve",
    })),
    re_path(r"^labels/(?P<id>-?\d+)/$", views.LabelallViewSet.as_view({
        "get": "retrieve_data",
    })),
    # 用户关注标签 labels/2/focusin/
    re_path(r"^labels/(?P<id>-?\d+)/focusin/$", views.LabelallViewSet.as_view({
        "put": "user_focusin_labels",
    })),
    # 用户取消关注标签 labels/2/focusout/
    re_path(r"^labels/(?P<id>-?\d+)/focusout/$", views.LabelallViewSet.as_view({
        "put": "user_focusout_labels",
    })),

    # 最新回答的问题 /questions/{id}/label/new/
    re_path(r"^questions/(?P<id>-?\d+)/label/new/$", views.QuestionViewSet.as_view({
        "get": "list",
        "post": "create",
    })),
    # 发布问题 http://127.0.0.1:8000/questions/
    re_path(r"^questions/$", views.QuestionViewSet.as_view({
        "post": "create",
    })),
    # 最热问题回答 questions/-1/label/hot/
    re_path(r"^questions/(?P<id>-?\d+)/label/hot/$", views.QuestionViewSet.as_view({
        "get": "list1",
    })),
    # 等待问题回答 /questions/{id}/label/wait/
    re_path(r"^questions/(?P<id>-?\d+)/label/wait/$", views.QuestionViewSet.as_view({
        "get": "list2",
    })),
    # 某一个问题详情 questions/2/
    re_path(r"^questions/(?P<id>-?\d+)/$", views.QuestionsModelViewSet.as_view({
        "get": "retrieve",
    })),
    # 问题有用 /questions/{id}/useful/
    re_path(r"^questions/(?P<id>-?\d+)/useful/$", views.QuestionsModelViewSet.as_view({
        "put": "update_useful_count",
    })),
    # 问题无用 questions/2/unuseful/
    re_path(r"^questions/(?P<id>-?\d+)/unuseful/$", views.QuestionsModelViewSet.as_view({
        "put": "update_unuseful_count",
    })),
    # 某一个标签中的问题questions/2/label/new/

    # 评论回答 ReplyViewSet reply/5/useful/
    re_path(r"^reply/$", views.ReplyViewSet.as_view({"post": "create"})),
    re_path(r"^reply/(?P<id>-?\d+)/useful/$", views.ReplyViewSet.as_view({"put": "update_useful_count"})),
    re_path(r"^reply/(?P<id>-?\d+)/unuseful/$", views.ReplyViewSet.as_view({"put": "update_unuseful_count"})),
]